from django.db import models 
from django.contrib.auth.models import User
from django.utils import timezone  
from django.db.models.signals import post_save
from django.dispatch import receiver

# class Profile(models.Model):
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
#     uid = models.CharField(max_length=10, unique=True)


# @receiver(post_save, sender=User)
# def create_user_profile(sender, instance, created, **kwargs):
#     if created:
#         Profile.objects.create(user=instance)
# @receiver(post_save, sender=User)
# def save_user_profile(sender, instance, **kwargs):
#     instance.profile.save()


  
class recording(models.Model):  
    username = models.CharField(max_length=30)# 用户名称,即账号
    uid = models.CharField(max_length=10) #用户id
    name =  models.CharField(max_length=10) #名字   
    date = models.DateField()               #参观日期 
    period = models.CharField(max_length=5) # 分为上午9:00~12:00/下午13:00~16:00
    status = models.CharField(max_length=7) # 分为待参观/已过期/已退票
    phone = models.CharField(max_length=20) #电话号码
    idcard = models.CharField(max_length=20)#身份证号
    created_at = models.DateTimeField(auto_now_add=True)#保存预约时间

    class Meta:
        unique_together = ('name', 'date', 'period')
    def __str__(self):  
        return self.name

    

    